$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'college/Select',
        datatype: "json",
        colModel: [
            { label: '学院/部门名称', name: 'collegeName', width: 100 ,key: true },
            { label: '学院/部门代码', name: 'collegeCode', width: 100 }
        ],
        viewrecords: true,
        height:'100%',
        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true,
        // rownumWidth: 25,
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
    el:'#rrapp',
    data:{
        q:{
            key: null
        },
        showList: true,
        title: null,
        term: {}
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function () {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{ 'collegeName': vm.q.key},
                page:page
            }).trigger("reloadGrid");
        },
        validator: function () {
            if(isBlank(vm.term.schoolAcademicYear)){
                alert("学年不能为空");
                return true;
            }

            if(isBlank(vm.term.schoolAcademicTerm)){
                alert("学期不能为空");
                return true;
            }
            if(isBlank(vm.term.startDate)){
                alert("开始时间不能为空");
                return true;
            }
            if(isBlank(vm.term.endDate)){
                alert("结束时间不能为空");
                return true;
            }
            if(isBlank(vm.term.currentTerm)){
                alert("当前学期不能为空");
                return true;
            }
            if(isBlank(vm.term.teachingWeekNum)){
                alert("教学周长度不能为空");
                return true;
            }
        }
    }
});